import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { TableColumn } from '@/types/table'
import { dateFormatter } from '@/utils/formatTime'
import { groupList} from '../indexData';

// 表单校验
export const rules = reactive({
  webHookUrl: [{ required: true, message: 'webHookUrl不能为空', trigger: 'blur' }],
  name: [{ required: true, message: '名称不能为空', trigger: 'blur' }],
})

// CrudSchema：https://doc.iocoder.cn/vue3/crud-schema/
const crudSchemas = reactive<CrudSchema[]>([
  {
    label: '发送时间',
    field: 'createTime',
    formatter: dateFormatter,
    isSearch:false,
    detail: {
      dateFormat: 'YYYY-MM-DD HH:mm:ss'
    }
  },
  {
    label: '',
    field: 'content',
    isSearch: true,
    isTable:false,
    isDetail:false
  },
  {
    label: '地震名称',
    field: 'name',
    isSearch: false,
  },
  {
    label: '文件',
    field: 'fileName',
    isSearch: false,
  },
  {
    label: '机器人名称',
    field: 'robotName',
    isForm:false,
    isSearch: false,
  },
  {
    label: '机器人名称',
    field: 'robotId',
    isDetail: false,
    isSearch: false,
    isTable:false,
    formatter: (_: Recordable, __: TableColumn, cellValue: number|string) => {
      return groupList.find((account) => account.id === cellValue)?.name
    },
  },
  
  {
    label: '发送状态',
    field: 'pslStatus',
    isForm:false,
    isDetail: false,
  },
])
export const { allSchemas } = useCrudSchemas(crudSchemas)
